using UnityEngine;

public class SingletonMono<T> : MonoBehaviour where T : MonoBehaviour
{
    private static T instance;
    public static T GetInstance()
    {
        return instance;
    }
    protected virtual void OnAwake() { }
    private void Awake()
    {
        if (instance == null)
        {
            if (gameObject != null)
            {
                DontDestroyOnLoad(this.gameObject);
                instance = GetComponent<T>();
            }
        }
        OnAwake();
    }
}
